gdkglcontext-win32.c: Create a global shared GL context
authorChun-wei Fan <fanchunwei@src.gnome.org>
Fri, 31 Jul 2020 10:37:05 +0000 (18:37 +0800)
committerChun-wei Fan <fanchunwei@src.gnome.org>
Fri, 31 Jul 2020 15:19:28 +0000 (23:19 +0800)
Like the other backends, we ought to create our WGL/EGL GL contexts like
the following:

"Create a global GL context that connects all GL contexts on a display
and lets us share textures between them."

gdk/win32/gdkglcontext-win32.c

index 056b6513556e981191eb20c5b1d099f48bc6c118..a500ffcddc3002f4f8cb0d736d4cf6d6e174cfc4 100644 (file)
@@ -937,6 +937,7 @@ gdk_win32_gl_context_realize (GdkGLContext *context,
                               GError **error)
 {
   GdkGLContext *share = gdk_gl_context_get_shared_context (context);
+  GdkGLContext *shared_data_context;
   GdkWin32GLContext *context_win32 = GDK_WIN32_GL_CONTEXT (context);
 
   gboolean debug_bit, compat_bit, legacy_bit;
@@ -955,6 +956,7 @@ gdk_win32_gl_context_realize (GdkGLContext *context,
   gdk_gl_context_get_required_version (context, &major, &minor);
   debug_bit = gdk_gl_context_get_debug_enabled (context);
   compat_bit = gdk_gl_context_get_forward_compatible (context);
+  shared_data_context = gdk_surface_get_shared_data_gl_context (surface);
 
   /*
    * A legacy context cannot be shared with core profile ones, so this means we
@@ -1004,7 +1006,7 @@ gdk_win32_gl_context_realize (GdkGLContext *context,
                           legacy_bit ? "yes" : "no"));
 
       hglrc = _create_gl_context (context_win32->gl_hdc,
-                                  share,
+                                  share ? share : shared_data_context,
                                   flags,
                                   major,
                                   minor,
@@ -1046,7 +1048,7 @@ gdk_win32_gl_context_realize (GdkGLContext *context,
 
       ctx = _create_egl_context (win32_display->egl_disp,
                                  context_win32->egl_config,
-                                 share,
+                                 share ? share : shared_data_context,
                                  flags,
                                  major,
                                  minor,